-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(jmc-core): update RJMX sources #228
Conversation
I tried this out combined with #222 and got this in the Cryostat logs when attempting to open a JMX connection to a native image application:
That first frame in the stack trace is this: if (!isDynamicFlightRecorderSupported(handle) && isFlightRecorderDisabled(handle)) {
throw new ServiceNotAvailableException(""); //$NON-NLS-1$
} When I hacked at updating the sources myself (see #222 (comment)) I had the private boolean isDynamicFlightRecorderSupported(IConnectionHandle handle) {
return !cfs.hasCommercialFeatures() || (ConnectionToolkit.isHotSpot(handle)
&& ConnectionToolkit.isJavaVersionAboveOrEqual(handle, JavaVersionSupport.DYNAMIC_JFR_SUPPORTED));
} I'm guessing that this means the further detection checks happening here also do not properly support whatever information the native image is providing about itself. I assume it wouldn't pass the @Override
public ICommercialFeaturesService getServiceInstance(IConnectionHandle handle)
throws ConnectionException, ServiceNotAvailableException {
JVMDescriptor descriptor = handle.getServerDescriptor().getJvmInfo();
if (descriptor != null) {
JavaVersion version = new JavaVersion(descriptor.getJavaVersion());
if (version.getMajorVersion() >= 11) {
return new Jdk11CommercialFeaturesService();
}
}
return new HotSpot23CommercialFeaturesService(handle);
} public static boolean isHotSpot(IConnectionHandle connectionHandle) {
String vmName = getVMName(connectionHandle);
return vmName != null && JavaVMVersionToolkit.isHotspotJVMName(vmName);
} |
I'll try to dig into this a bit deeper later. Maybe @roberttoyonaga will be back to take a look before I get the chance. |
Though, I think Robert has said before that he was able to connect to his native image application using JMC before, so it seems like that code path should work here too... |
That error message comes up in the recording wizard [0] looking for the type of the jvm type [1] [2]. I just noticed that the jvmtype for other goes unchecked, and I'm wondering if that's where this is falling into. I'm not too familiar with graalvm, but tried launching a quarkus demo app with the graalvm-ce [3] and it was able to start jfr. @roberttoyonaga Is there a place to easily grab (or build?) a copy of the graalvm you're using here? [0]https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.flightrecorder.controlpanel.ui/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/actions/StartRecordingAction.java#L64 |
@aptmac hmm you could try using one of the dev builds here: https://github.com/graalvm/graalvm-ce-dev-builds/releases |
Thanks @Josh-Matsuoka @aptmac @roberttoyonaga all for looking into this, this is a lot of help. Since JMC is also affected in some manner it does look like we should propose a patch. We can experiment with our embedded sources and try to come up with something that works, which should then be pretty trivial to port over to JMC to verify a build, and then try to upstream the change. I'm fine with carrying a downstream patch to fix this for our particular case in the meantime. |
I'm going to experiment a little. I think I know what the problem is ( |
diff --git a/pom.xml b/pom.xml
index 989b393f..36cf14c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
<cryostat.imageStream>quay.io/cryostat/cryostat</cryostat.imageStream>
<cryostat.entrypoint>/app/entrypoint.bash</cryostat.entrypoint>
<cryostat.mainClass>io.cryostat.Cryostat</cryostat.mainClass>
- <cryostat.rjmxPort>9091</cryostat.rjmxPort>
+ <cryostat.rjmxPort>9081</cryostat.rjmxPort>
<cryostat.webPort>8181</cryostat.webPort>
<cryostat.itest.pullImages>always</cryostat.itest.pullImages>
<cryostat.itest.webPort>8181</cryostat.itest.webPort>
diff --git a/smoketest.sh b/smoketest.sh
index f0ec590b..2947e45b 100755
--- a/smoketest.sh
+++ b/smoketest.sh
@@ -108,6 +108,12 @@ runDemoApps() {
local protocol="http"
fi
+ podman run \
+ --name robert-app \
+ --pod cryostat-pod \
+ --label io.cryostat.connectUrl="service:jmx:rmi:///jndi/rmi://localhost:9091/jmxrmi" \
+ --rm -d quay.io/roberttoyonaga/jmx:jmxquarkus
+
podman run \
--name vertx-fib-demo-1 \
--env HTTP_PORT=8081 \
@@ -295,6 +301,7 @@ createPod() {
--publish 8081:8081 \
--publish 8082:8082 \
--publish 8083:8083 \
+ --publish 9091:9091 \
--publish 9093:9093 \
--publish 9094:9094 \
--publish 9095:9095 \ $ cd cryostat
$ patch -p1 < diff-above.patch
$ sh smoketest.sh h2mem $ cd cryostat-core
$ # make changes, check out PR branch, whatever
$ vim pom.xml # update artifact version to some later number
$ mvn install
$ cd cryostat # wherever that is
$ vim pom.xml # update core.version property to correspond to version used above
$ mvn clean package ; podman image prune -f
$ sh smoketest.sh h2mem # cryostat server should now be running with new -core changes included |
Oh on this note since you're back @roberttoyonaga , can the JMX port for your native image application be controlled, or is it hardcoded to bind on 9091? The |
Oh I see. Nope, I hard-coded it to be 9091 in the Dockerfile |
Okay, no problem. The patch I shared already accounts for that and binds Cryostat's JMX port on a different number to avoid the conflict, so it should still work that way. It just happens like that because |
Thanks! That was a big help, I see the errors now. JMC basically checks to see if the jvm is HotSpot, and bails otherwise. For a bit more context, here's an example of what it's going through
[1]https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.rjmx.services.jfr/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java#L131 |
I'm having a bit of trouble running smoketest.sh. In |
I've seen similar things before when people have tried to run the script on RHEL, which has an older kernel and an older version of cgroups. You can just edit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested some changes that add handling for substrate VM and should resolve the problem you were seeing. I tested this out with devserver.sh (I had issues getting smoketest.sh to run on my machine) and it seems to work now. I'm able to connect with Cryostat and generate/download recordings for a native image target. However, I noticed 2 problems:
- Cryostat no longer automatically detects native images. When I tested a few months ago, it was able to detect them without issue. Now I need to manually provide a custom service URL.
- I get this exception. I occasionally. Maybe this is because I'm testing with devserver.sh? It doesn't seem to affect functionality so I haven't looked into this further.
src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java
Show resolved
Hide resolved
src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java
Outdated
Show resolved
Hide resolved
@roberttoyonaga that exception gist in point |
For point 1 regarding automatic discovery, it will just depend on what kind of discovery mechanisms are available. In the devserver setup the only applicable builtin discovery mechanism will be JDP, otherwise targets will only be discovered as Custom Targets or if they have the Cryostat Agent attached and configured. I'm not sure what has changed in the scenario since the last time you tested it, but I don't think it has to do with this patch. |
Yes, I also don't think the changes in this PR have any affect on the discovery. I might dig deeper into it later, but for now, and for the purpose of the Quarkus insight demo, I think using a custom URL is good enough. |
If we can figure out how to run the demo using |
…nnectionHandle changes
Co-authored-by: Robert Toyonaga <rtoyonag@redhat.com>
e9bb092
to
35e963c
Compare
* Updating missed RJMX classes * Fixing newline at end of file * Cleanup of CommercialFeaturesServiceFactory, adding missing DefaultConnectionHandle changes * feat(jmx): check for SubstrateVM and whether JFR is available Co-authored-by: Robert Toyonaga <rtoyonag@redhat.com> --------- Co-authored-by: Andrew Azores <aazores@redhat.com> Co-authored-by: Robert Toyonaga <rtoyonag@redhat.com> (cherry picked from commit 4bc004e)
* Updating missed RJMX classes * Fixing newline at end of file * Cleanup of CommercialFeaturesServiceFactory, adding missing DefaultConnectionHandle changes * feat(jmx): check for SubstrateVM and whether JFR is available Co-authored-by: Robert Toyonaga <rtoyonag@redhat.com> --------- Co-authored-by: Andrew Azores <aazores@redhat.com> Co-authored-by: Robert Toyonaga <rtoyonag@redhat.com> (cherry picked from commit 4bc004e) Co-authored-by: Joshua Matsuoka <Josh.matsuoka@gmail.com>
Updating the missed RJMX classes to resolve the NullPointer when checking for JFR availability in native images.
Fixes #223